const jsonServer = require("json-server");
const $db = require(__dirname + "/db.json");
const server = jsonServer.create();
const middlewares = jsonServer.defaults();

const path = require("path");

server.use(
  jsonServer.defaults({
    static: path.join(__dirname, "/public"), //静态资源托管
  })
);

const router = jsonServer.router($db);
 
server.use(router);
server.use(middlewares);
server.use(jsonServer.bodyParser);
// let port = process.env.PORT;   
let port = 9007;   
server.listen(port, () => {
  console.info("服务已启动, 在 http://localhost:"+port);
});
